import { _decorator, Component, Node } from 'cc';
import { PlayerState } from './PlayerState';
import { StateDefine } from '../../Config';
import { SkillManager } from '../../../Skill/SkillManager';
import { Skill } from '../../../Skill/Skill';
const { ccclass, property } = _decorator;

@ccclass('PlayerDashState')
export class PlayerDashState extends PlayerState {
    time = null;
    onEnter() {
        super.onEnter();
        this.time = this.player.DashDuration;
        this.player.Skill.clone_Skill.createClone(this.player.node.getWorldPosition())
    }
    onExit() { 
        super.onExit();
        this.player.setVelocity(0,0);
    }
    update(deltaTime: number) {
        super.update(deltaTime);
        this.player.setVelocity(this.player.DashDir*this.player.DashSpeed,0);
        this.time -= deltaTime;
        if(this.time<0){
            this.player.stateMgr.transit(StateDefine.Idle);
        }
    }
    onDestory() { }
    canTransit(to: StateDefine): boolean {
        return true;
    }
}


